<?php

/**
 * Credit filter form base class.
 *
 * @package    dashboard
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseCreditFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'credit_date'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'credit_amount' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'credit_desc'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'credit_type'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'account_id'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'invoice_id'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'credit_date'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'credit_amount' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'credit_desc'   => new sfValidatorPass(array('required' => false)),
      'credit_type'   => new sfValidatorPass(array('required' => false)),
      'account_id'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'invoice_id'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('credit_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Credit';
  }

  public function getFields()
  {
    return array(
      'credit_id'     => 'Number',
      'credit_date'   => 'Date',
      'credit_amount' => 'Number',
      'credit_desc'   => 'Text',
      'credit_type'   => 'Text',
      'account_id'    => 'Number',
      'invoice_id'    => 'Number',
    );
  }
}
